<?php
/**
 * Created by PhpStorm.
 * User: jiang
 * Date: 2019/6/1
 * Time: 10:27
 */

namespace app\api\controller;
use app\api\model\ApplyshopModel;


class Applyshop extends BaseController
{
    public function __construct()
    {
        parent::__construct();
        $this->shop = new ApplyshopModel();
    }
    public function AjaxReturn($code,$msg,$data=array())
    {

        $returnData=array(
            "code"=>$code
        );
        if($msg)
        {
            $returnData["message"]=$msg;
        }
        if(!empty($data))
        {
            $returnData["data"]=$data;
        }
        exit(json_encode($returnData));
    }
    public function shopadd(){//申请开店
        $uid=2;
        $type=input('type');
        $name=input('name');
        $address=input('address');
        if($uid==''||$name==''||$type==''||$address=''){
            return $this->AjaxReturn('3','必填');
        }
        $res=$this->shop->shopadd($uid,$type,$name,$address);
        if(!empty($res)){
            return $this->Ajaxreturn('1','成功');
        }else{
            return $this->Ajaxreturn('0','失败');
        }
    }
    public function shoplist(){//商品类型下拉列表
        $list=$this->shop->shoplist();
        if (!empty($list)){
            return $this->AjaxReturn('1','成功',$list);
        }else{
            return $this->AjaxReturn('0','查询失败');
        }
    }
}